package com.yoomiito.app.address

import cn.droidlover.xdroidmvp.net.ApiException
import cn.droidlover.xdroidmvp.net.ApiSubscriber
import cn.droidlover.xdroidmvp.net.XApi
import com.yoomiito.app.base.AppConfig
import com.yoomiito.app.base.BaseActPresenter
import com.yoomiito.app.model.BaseList
import com.yoomiito.app.model.bean.AddressInfo
import com.yoomiito.app.net.YmApi
import com.yoomiito.app.utils.L

class AddressListPresenter(appConfig: AppConfig) :BaseActPresenter<AddressListActivity>(appConfig){

    fun addressList(page:Int=1){
        YmApi.getYmService()
                .getAddressList(page)
                .compose(v.bindToLifecycle())
                .compose(XApi.getApiTransformerData())
                .compose(XApi.getScheduler())
                .subscribe(object :ApiSubscriber<List<AddressInfo>>(){

                    override fun onSuccess(t: List<AddressInfo>?) {
                        v.setData(t!!)
                    }

                    override fun onFail(error: ApiException?) {
                    }

                })
    }
}